<?php 
include("db.php");
include("fileop.php");
?>

<?php

$con=mysqli_connect(DBADDR,DBUSER,DBPWD,DBNAME);
mysql_query('set names utf8'); 
// Check connection
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  echo "Returning in 5 seceonds";
  header("refresh:5;url=allresto.php");
}

$namefr = $_POST['namefr'];
$namearb = $_POST['namearb'];
$restoredu = $_POST['restoredu'];
$restotype = $_POST['restotype'];
$restonation = $_POST['restonation'];
$tel = $_POST['tel'];
$address = $_POST['address'];
$mail = $_POST['mail'];
$descfr = $_POST['descfr'];
$descarb = $_POST['descarb'];
$opentimefr = $_POST['opentimefr'];
$opentimearb = $_POST['opentimearb'];
$hasreserv = isset($_POST['hasreserv'])? 1 : 0;
$hascoupon = isset($_POST['hascoupon'])? 1 : 0;
$intropic = isset($_FILES["intro_pic"])? addfile('intro_pic'): "";
$website=$_POST['website'];


$sql = "INSERT INTO `inforesto`.`info_resto` 
(`RESTO_ID`, `RESTO_TYPE_ID`, `RESTO_NAME_FR`, `RESTO_NAME_ARB`, `RESTO_INTRO_ARB`, `RESTO_INTRO_FR`, 
`RESTO_WEBSITE`, `RESTO_NATION`, `RESTO_ADDR`, `RESTO_MAIL`, `RESTO_TIME_FR`, `RESTO_TIME_ARB`, `RESTO_TEL`,
 `RESTO_REDU`, `HAS_COUPON`, `HAS_RESERV`, `INTRO_PIC`) VALUES 
 (NULL, '".$restotype."', '".$namefr."', '".$namearb."', '".$descarb."', '".$descfr."', '".$website."', '".$restonation."', '".$address."', '".$mail."', '".$opentimefr."', '".$opentimearb."', '".$tel."', '".$restoredu."', b'".$hascoupon."', b'".$hasreserv."', '".$intropic."');";

mysqli_query($con,$sql);

mysqli_close($con);

header("Location:allresto.php?succ=1&type=a");


?>